<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>SQL操作</title>
        <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
	<script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        .list{
            width: 80%;
        }
    </style>
</head>
<body>

<center>
<form method="post">
{%csrf_token%}
<h2>请输入SQL:</h2>
    {% if sql %}
    <textarea name="sql" id="sql" cols="100" rows="5">{{sql}}</textarea><br>
    {% else %}
    <textarea name="sql" id="sql" cols="100" rows="5"></textarea><br>
    {% endif %}
    <input type="submit" value="提交">
</form>
<br>

    {% if data %}
    <div class="list">
    <table border="1" style="border-collapse: collapse"  class="table table-striped table-bordered table-hover mytable">
        <tr>
        {% for i in title %}
        <th>{{i}}</th>
         {% endfor %}
        </tr>

        {% for i in data %}

        <tr>
            <td>{{i.username}}</td>
            <td>{{i.passenger}}</td>
            <td>{{i.update_time|date:"Y-m-d H:i:s"}}</td>
            <td>{{i.password}}</td>
            <td>{{i.remark}}</td>
            <td>{{i.order_id}}</td>
            <td>{{i.login_user}}</td>
            <td>{{i.start_time}}</td>
            <td>{{i.train_no}}</td>
            <td>{{i.state}}</td>
            <td>{{i.seat}}</td>
            <td>{{i.arrive_time}}</td>
            <td>{{i.arrive_station}}</td>
            <td>{{i.start_station}}</td>
            <td>{{i.train_date|date:"Y-m-d"}}</td>
        </tr>

        {% endfor %}

    </table>
        </div>
    {% endif %}
</center>
</body>
</html>